The given linens have different properties naturally. For instance, the angle of the pattern on the linen fluctuates from one image to another. Therefore the parameters of the Gabor Filter function have to be changed according to the linen. Looking from the industrial perspective, the machine that will decide whether the linen has defects or not can be arranged (the code can be updated with respect to the features of the linen). The issue of automatization can be solved by some learning approaches. The properties of linens can be given to the prediction models and the features like "angle of the pattern", "width of the pattern", etc. can be estimated when a different type of linen first observed. So that parameters below are determined before the detection part and assigned to arrays.
Images are imported and then gabor filtered with respect to the parameters below. Filtered_image output of the gabor filter function’s 262144 pixel values are normalized for the sake of simplicity and now can be handled as a sample from a greater population. 3-sigma limits control chart is selected and sample mean and sample standard deviation are the estimators for population parameters. 20 control charts are constructed for 20 different fabric images and the pixels out of limits are labeled as defective. First control charts are shown below. And after that on the left hand side original greyscale image is available. On the right hand side, the white pixels are labeled as defects.
library(jpeg)
library(wvtool)
l<-c(18,18,12,72,10,48,30,40,24,15,50,30,30,50,30,30,80,100,160,80)
t<-c(0,0,110,120,90,90,90,110,60,90,130,150,150,90,100,100,100,100,100,100)
b<-c(6,6,10,12,10,24,30,10,16,3,30,20,20,50,20,20,30,30,30,20)
p<-c(40,40,40,40,100,0,3,40,0,50,40,40,40,40,40,40,40,40,40,40)
a<-c(1.5,1.5,1,1.5,0,3,3,2,1.5,0,5,3,3,6,3,3,3,3,3,3)
for (f in 1:20) {
image <- readJPEG(paste("Fabric",f,".jpg",sep = ""))
image <- image[,,1]
par(mfrow=c(1,1))
test <- gabor.filter(x=image, lamda=l[f], theta=t[f], bw=b[f], phi=p[f], asp=a[f],disp=FALSE)
y <- test$filtered_img
max <- max(y)
min <- min(y)
for(i in 1:512){
for(j in 1:512){
y[i,j] <- (y[i,j]-min)/(max-min)
}
}
mean <- mean(y)
sd <- sd(y)
y_cont <- y
plot(1:(512*512),y_cont,main="Control Chart")
abline(h=mean+sd*3,col="blue")
abline(h=mean-sd*3,col ="blue")
for( i in 1:512){
for(j in 1:512){
if(y[i,j]<= mean - 3*sd | y[i,j]>= mean + 3*sd){
y[i,j] = 1
}
else{y[i,j] = 0}
}
}
par(mfrow=c(1,2))
plot(as.raster(image),main="Original Image")
plot(as.raster(y),main="Defectives Detected")
}
On overall the code works well and defects on the linen are detected. But the main drawback of this application might have been solved by eliminating the heuristic parameter determination part with the use of neural networks or other algorithms. Some of the fabric images are not very suitable for greyscaling and the algorithm haven’t performed well on those. After greyscaling the pixel values’ variance is decreased. So that the assumption of normality between pixels sometimes pushed non-defective elements to out of the limits. K-sigma limits can be determined with respect to the industry standards in order to overcome the associated problem.